package site.xuxingcan.autologin;

import android.content.Context;
import android.content.SharedPreferences;

import com.google.gson.Gson;

public class SharedPreferenceUtil {
    private static volatile SharedPreferenceUtil instance = null;
    private Gson gson;

    public static SharedPreferenceUtil getInstance() {
        if (instance == null) {
            synchronized (SharedPreferenceUtil.class) {
                if (instance == null) {
                    instance = new SharedPreferenceUtil();
                }
            }
        }
        return instance;
    }

    private SharedPreferences mSharedPreferences;

    private SharedPreferenceUtil() {
        gson = new Gson();
        mSharedPreferences = MyApplication.mContext.getSharedPreferences("default", Context.MODE_PRIVATE);
    }

    public void setIsMove(boolean s) {
        mSharedPreferences.edit().putBoolean("IsMove", s).apply();
    }

    public boolean getIsMove() {
        return mSharedPreferences.getBoolean("IsMove", false);
    }

    public void setIsShowHome(boolean s) {
        mSharedPreferences.edit().putBoolean("IsShowHome", s).apply();
    }

    public boolean getIsShowHome() {
        return mSharedPreferences.getBoolean("IsShowHome", true);
    }

    public void setLianZongUser(String s) {
        mSharedPreferences.edit().putString("LianZongUser", s).apply();
    }

    public String getLianZongUser() {
        return mSharedPreferences.getString("LianZongUser", "");
    }

    public void setLianZongPwd(String s) {
        mSharedPreferences.edit().putString("LianZongPwd", s).apply();
    }

    public String getLianZongPwd() {
        return mSharedPreferences.getString("LianZongPwd", "");
    }

    public void setYunmaUser(String s) {
        mSharedPreferences.edit().putString("YunmaUser", s).apply();
    }

    public String getYunmaUser() {
        return mSharedPreferences.getString("YunmaUser", "");
    }

    public void setYunmaPwd(String s) {
        mSharedPreferences.edit().putString("YunmaPwd", s).apply();
    }

    public String getYunmaPwd() {
        return mSharedPreferences.getString("YunmaPwd", "");
    }

    /**
     * 0 联众 1 云码
     */
    public void setDaMa(int s) {
        mSharedPreferences.edit().putInt("DaMa", s).apply();
    }

    /**
     * 0 联众 1 云码
     */
    public int getDaMa() {
        return mSharedPreferences.getInt("DaMa", 0);
    }
}
